package br.ufrj.ppgi.infovis.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mt4j.util.MTColor;

import br.ufrj.ppgi.infovis.styles.Category;
import br.ufrj.ppgi.infovis.styles.Configuration;

public class TestXMLConfigImport {
	
	private Configuration config;
	private final String path = "tests/br/ufrj/ppgi/infovis/util/config.xml";
	
	@Before
	public void startUP(){
		
		XMLConfigImport importer = new XMLConfigImport(path);
		
		config = importer.Import();
	}
	
	@Test
	public void testConfigurationName(){
		Assert.assertEquals("Academia", config.getTitle());		
	}
	
	@Test
	public void testCategoryNames(){
		Set<String> expected = new HashSet<String>();
		
		expected.add("Professor");
		expected.add("Aluno");
		expected.add("Disciplina");
		
		Category[] actualCategories = config.getCategories();
		
		ArrayList<String> actualNamesList = new ArrayList<String>();
		for (Category c : actualCategories){
			actualNamesList.add(c.getName());
		}
		
		Assert.assertTrue(expected.containsAll(actualNamesList));
	}
	
	
	@Test
	public void testCategoryColors(){
		
		Set<MTColor> expected = new HashSet<MTColor>();
		expected.add(new MTColor(27, 76, 224));//1B4CE0
		expected.add(new MTColor(224,27,106)); //E01B6A
		expected.add(new MTColor(108, 196, 26)); //6CC41A
		
		Category[] actualCategories = config.getCategories();
		
		ArrayList<MTColor> actualColorsList = new ArrayList<MTColor>();
		for (Category c : actualCategories){
			actualColorsList.add(c.getColor());
		}
		
		Assert.assertTrue(expected.containsAll(actualColorsList));
	}
	
	

}
